package com.woniu.adapter;

import com.woniu.outlet.mysql.dao.RiskDao;
import com.woniu.outlet.mysql.po.Risk;
import com.woniu.outlet.mysql.po.RiskExample;
import com.woniu.service.domain.RiskDto;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RiskRepositoryApater {
    @Autowired
    private RiskDao riskDao;

    //根据RiskExample查询
    public List<Risk> selectByExample(RiskExample example) {
        List<Risk> risks = riskDao.selectByExample(example);
        return risks;
    }

    //根据id 查询risk
    public RiskDto getById(Integer id) {
        Risk risk = riskDao.selectByPrimaryKey(id);
        RiskDto riskDto = new RiskDto();
        BeanUtils.copyProperties(risk, riskDto);
        return riskDto;
    }
}
